package com.qg.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.qg.dto.ReturnResult;
import com.qg.dto.ReturnResultUtils;
import com.qg.pojo.QgUser;
import com.qg.service.LocalQgUserService;
import com.qg.util.EmptyUtils;
import com.qg.vo.QgUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api",method = RequestMethod.POST)
public class QgUserController {
    /**
     * 登录
     * @param phone
     * @param password-
     * @return
     */
    @Autowired
    private LocalQgUserService localQgUserService;

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public ReturnResult LoginUser(String phone, String password) throws Exception {
        QgUserVo qgUser=localQgUserService.UserLogin(phone,password);
        if (EmptyUtils.isEmpty(qgUser)){
            return ReturnResultUtils.returnFail(1001,"用户或密码错误");
        }

        String userJson= JSON.toJSONString(qgUser);
        return ReturnResultUtils.resultSuccess(userJson);
    }

    /**
     * 注销
     * @param id
     * @return
     */
    public ReturnResult OutFail(String id){

        return null;
    }
}